package com.aikon.wht.ref;

import javax.naming.Context;
import javax.naming.Name;
import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
import java.util.Hashtable;

/**
 * @author haitao.wang http://www.bestwonderful.com
 */
public class DefaultObjectFactory implements ObjectFactory {
    @Override
    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
        Reference reference = (Reference) obj;
        return this.getClass().getClassLoader().loadClass(reference.getClassName()).newInstance();
    }
}
